#include <stdio.h>
#include <string.h>

int main()
{
    char T[1000];
    int res;
    int r = 0, l = 0;
    int loc = 0;

    scanf("%s", T);
    int len = strlen(T);

    //三角
    int n[1000] = {0};
    n[0] = 1;
    for(int i = 1; i <= len; i++){
        n[i] = n[i-1]*2;
    }

    //最后一个5
    for(int i = len-1; i >= 0; i--){
        if('5' == T[i]){
            loc = i;
        }
    }

    l = loc;
    r = len-1-loc;

    res = n[r]-1+n[l]-1;
    printf("%d\n", res);

    return 0;
}
